package de.bazinga.rotw.network;

import com.captiveimagination.jgn.event.MessageListener;
import com.captiveimagination.jgn.message.Message;
import com.jmex.game.state.GameStateManager;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.map.MapList;
import de.bazinga.rotw.network.message.MapMessage;

public class ClientMapListener implements MessageListener {
	public void messageCertified(Message arg0) {}
	
	public void messageFailed(Message arg0) {}
	
	public void messageReceived(Message msg) {
		if(msg instanceof MapMessage) {
        	int mapIndex = MapList.getInstance().getIndexByName(((MapMessage)msg).getMapName());
        	if(mapIndex >= 0) {
        		((RotwGameState)GameStateManager.getInstance().getChild("gameState")).reset(mapIndex);

        		System.out.println("Reset map "+mapIndex);
        	}	
        }
	}

	public void messageSent(Message msg) {}
}
